<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header">

</head>
<body class="hold-transition skin-blue sidebar-mini">
<style>
    .table-border tbody tr td{
        border-top: 1px solid black;
    }
</style>
<section class="content-header">
    <h1>
       待签合同列表
    </h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <!--<div class="form-group" style="margin-right: 10px;">-->
                                    <!--<label>报价单编号</label>-->
                                    <!--<input type="text" name="quoteNo" class="form-control" placeholder="报价单编号">-->
                                <!--</div>-->
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>项目编号</label>
                                    <input type="text" name="contName" class="form-control" placeholder="项目编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>买方名称</label>
                                    <input type="text" name="consumerName" class="form-control" placeholder="买方名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>卖方名称</label>
                                    <input type="text" name="supplierName" class="form-control" placeholder="卖方名称">
                                </div>


                                <!--<div class="form-group" style="margin-right: 10px;margin-top: 5px;">-->
                                    <!--<label>合同任务状态</label>-->
                                    <!--<select name="isStatue" class="form-control">-->
                                        <!--<option value="" selected="selected">全部</option>-->
                                        <!--<option  value="0">未开始</option>-->
                                        <!--<option  value="2">执行中</option>-->
                                        <!--<option  value="3">已完结</option>-->
                                    <!--</select>-->
                                <!--</div>-->

                                <!--<div class="form-group" style="margin-right: 10px;">-->
                                    <!--<label>报价创建人</label>-->
                                    <!--<input type="text" name="supplierAttn" class="form-control" placeholder="报价创建人">-->
                                <!--</div>-->
                                <!--<div class="form-group" style="margin-right: 10px;">-->
                                    <!--<label>报价时间</label>-->
                                    <!--<input type="text" name="quoteGentDate" class="form-control" placeholder="报价创建时间">-->
                                <!--</div>-->

                                <button type="button" class="btn btn-success" id="btn-search" style="margin-top: 5px;">
                                    <!--<i class="fa fa-search"></i>-->
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"  class="table-border" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer">
</div>
<script th:inline="javascript">
    /** 加载用户表格 */
    table = js.table.init({
        url: ctx + "contractManage/selUnContractList",
        showColumns: true,
        showExport: true,
        pageSize:10,
        columns: [
            {
                title: '序号', field: 'id', width: '50',
                formatter: function (value, row, index, field) {
                    var pageSize = table.bootstrapTable('getOptions').pageSize;
                    var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                    return pageSize * (pageNumber - 1) + index + 1;
                }
            },
            { title: "项目编号", field: 'contName'},
            // { title: "报价单编号", field: 'quoteNo'},
            { title: "买方名称", field: 'consumerName'},
            { title: "卖方名称", field: 'supplierName'},
            { title: "包含项目", field: 'name'},
            { title: "报价总金额", field: 'totalAmountIncludedTax'},
            { title: "报价创建人", field: 'supplierAttn'},
            { title: "创建时间", field: 'quoteGentDate'},
            { title: "合同任务状态", field: 'isStatue',
                formatter: function (value, row, index) {
                    if(value==3){
                        return '<span class="label  badge  label-success">已完成</span>';
                    }else if(value==2){
                        return '<span class="label  badge  label-warning">执行中</span>';
                    }else if (value==4) {
                        return '<span class="label  badge  label-danger">被驳回</span>';
                    }else{
                        return '<span class="label  badge  label-default">未开始</span>';
                    }
                }
            },
            {
                title: "操作",
                width: '110',
                    formatter: function (value, row, index) {
                    var actions = [];
                    // if(row.isStatue == null || row.isStatue ==''){
                        if (hasP('con:register:register')) {
                            actions.push('<a class="btn btn-success btn-xs" href="' + ctx + 'contractManage/contractInfo?quoteId=' + row.quoteId + '&conId=0"> 合同登记</a> ');
                        }
                        if (hasP('quo:await:view')) {
                            actions.push('<a class="btn btn-bitbucket btn-xs" target="_blank" href="' + ctx + 'quoteManage/viewQuotation/quoteId/' + row.quoteId + '"> 查看报价</a> ');
                        }
                    // }
                    // else  if(row.isStatue<2) {
                    //     actions.push('<a shiro:hasPermission="con:register:edit" class="btn btn-warning btn-xs" href="'+ ctx + 'contractManage/contractInfo?quoteId=' + row.quoteId + '&conId=' + row.id + '" > 编辑合同</a> ');
                    //     actions.push('<a shiro:hasPermission="con:await:view" class="btn btn-bitbucket btn-xs" href="'+ ctx + 'quoteManage/viewQuotation/quoteId/'+ row.quoteId+'"> 查看报价</a> ');
                    //     actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApp(' + row.id + ')"> 提交审核</a> ');
                    // }else if(row.isStatue==2){
                    //     actions.push('<a shiro:hasPermission="con:await:view" class="btn btn-bitbucket btn-xs" href="'+ ctx + 'quoteManage/viewQuotation/quoteId/'+ row.quoteId+'"> 查看报价</a> ');
                    //     // actions.push('<a class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/showDetail?quoteId=' + row.quoteId + '&conId=' + row.id + '"> 查看合同</a> ');
                    //     actions.push('<a shiro:hasPermission="con:regList:view"  class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/lookContract?quoteId=' + row.quoteId + '&conId=' + row.id + '&parentId=' + row.parentId + '"> 查看合同</a> ');
                    // }
                    // else if(row.isStatue==3){
                    //     actions.push('<a shiro:hasPermission="con:await:view" class="btn btn-bitbucket btn-xs" href="'+ ctx + 'quoteManage/viewQuotation/quoteId/'+ row.quoteId+'"> 查看报价</a> ');
                    //     // actions.push('<a class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/showDetail?quoteId=' + row.quoteId + '&conId=' + row.id + '"> 查看合同</a> ');
                    //     actions.push('<a shiro:hasPermission="con:regList:view" class="btn btn-info btn-xs" href="'+ ctx + 'contractManage/lookContract?quoteId=' + row.quoteId + '&conId=' + row.id + '&parentId=' + row.parentId + '"> 查看合同</a> ');
                    //     actions.push('<a shiro:hasPermission="con:agr:view" class="btn btn-success btn-xs" href="'+ ctx + 'contractManage/contractInfoAppend?quoteId=' + row.quoteId + '&conId=0&parentId=' + row.id + '"> 增补协议</a> ');
                    // }
                    // else if(row.isStatue==4){
                    //     actions.push('<a shiro:hasPermission="con:register:edit"  class="btn bg-maroon btn-xs " href="'+ ctx + 'contractManage/contractInfo?quoteId=' + row.quoteId + '&conId=' + row.id + '" > 编辑合同</a> ');
                    //     actions.push('<a shiro:hasPermission="con:await:view" class="btn btn-bitbucket btn-xs" href="'+ ctx + 'quoteManage/viewQuotation/quoteId/'+ row.quoteId+'"> 查看报价</a> ');
                    //     actions.push('<a  class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApp(' + row.id + ')"> 提交审核</a> ');
                    // }
                    return actions.join('');
                }
            }
        ]
    });
    /**
     * 表格搜索
     */
    $("#btn-search").click(function () {
        js.table.search(table);
    });

    /**
     * 合同id
     * @param contid
     */
    function submitApp(contid){
        js.post({
            url: ctx + "contractManage/contractAppInfo",
            data:{"conId":contid},
            success: function (result) {
                if (result.type === web_status.SUCCESS) {

                    js.modal.success(result.msg);
                    js.table.refresh(table);
                } else {
                    js.modal.warning(result.msg);
                }
                js.modal.closeLoading();
            }
        });
    }
</script>